package com.qzsoft.zhjd.upload.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.common.utils.ResultUtils;
import com.qzsoft.zhjd.upload.service.UploadService;

/**
 * @ClassName UploadController
 * @Description 文件上传控制器
 * @author linhuawei
 * @since 2021-10-29
 */
@RestController
@RequestMapping("/api/upload")
public class UploadController {
    
    @Autowired
    private UploadService uploadService;
    
    /**
     * @Title image
     * @Description 上传图片
     * @param file 上传文件
     * @return 上传结果
     */
    @PostMapping("/image")
    public Result<String> image(@RequestParam(required = false,name = "file") MultipartFile file){
        String url = uploadService.upload(file, "image");
        return ResultUtils.ok(url);
    }

}
